import request from '@/utils/request'
/**
 * 注册接口
 * @param {*} param0 { username: 用户名, password: 密码 }
 * @returns Promise对象
 */
// export const login = ({ username, password }) => {
//   return request({
//     url: '/login',
//     method: 'Get',
//     params: {
//       username,
//       password
//     }
//   })
// }
export const getuser = () => {
  return request({
    url: '/userInfo/getAllStuUsers',
    method: 'Get'
  })
}
export const getdept = () => {
  return request({
    url: '/sys/dept',
    method: 'Get'
  })
}
// pagenum: 当前页码数, pagesize: 当前页条数
// export const inituser = (pagenum, pagesize) => {
//   return request({
//     url: '/sys/inituserinfo',
//     method: 'Get',
//     params: {
//       pagenum,
//       pagesize

//     }
//   })
// }

export const registerAPI = (nickname, username, password) => {
  return request({
    url: '/register',
    method: 'post',
    data: {
      nickname,
      username,
      password
    }
  })
}
//学生登录
export const login = ({ stu_phone, stu_password }) => {
  return request({
    url: '/userInfo/stuLogin',
    method: 'get',
    params: {
      stu_phone,
      stu_password
    }
  })
}
// page: 当前页码数, limit: 当前页条数
export const inituser = (page, limit) => {
  return request({
    url: '/userInfo/findUserByPageAndLimit',
    method: 'Get',
    params: {
      page,
      limit
    }
  })
}

// 编辑用户
export const edituser = (id, deptId, email, phone, sex) => {
  return request({
    url: '/updateSysUserById',
    method: 'post',
    data: {
      id, deptId, email, phone, sex
    }
  })
}
export const updateSysUserStatus = (id, status) => {
  return request({
    url: '/updateSysUserStatus',
    method: 'post',
    data: {
      id, status
    }
  })
}
export const addSysUserApI = (deptId, email, nickname, password, phone, sex, username) => {
  return request({
    url: '/addSysUser',
    method: 'post',
    data: {
      deptId,
      email,
      nickname,
      password,
      phone,
      sex,
      username
    }
  })
}

export const deleteSysUserByIdApI = (id) => {
  return request({
    url: '/deleteSysUserById',
    method: 'post',
    data: {
      id, status
    }
  })
}

export const findSysUserByNameApI = (admin_phone) => {
  return request({
    url: '/userInfo/findSysUserByName',
    method: 'get',
    params:{
      admin_phone
    }
    
  })
}

export const updatePwdAPI = (id, password) => {
  return request({
    url: '/updateSysUserPasswordById',
    method: 'post',
    data: {
      id, password
    }
  })
}
